{include file="common/head"/}
<div class="admin-main layui-anim layui-anim-upbit">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>衍界笔试题</legend>
        <div>
            <div>1、平台的用户敏感信息以及密码应该以什么形式保存，需要用到哪些技术？</div>
            <div>采用加密算法和加salt机制</div>
            <div>2、平台api 接口怎么保证安全性？爬虫爬取应该怎么防护？</div>
            <div>采用token refreshtoken 请求频率限制，ip限制，refer判断，允许指定域名，接口数据加密</div>
            <div>3、服务器内存100M，如何去查看服务器 10G 的日志并查找出其中的 ip 地址？请写出可能的 linux 命令</div>
            <div>首先增加虚拟内存并开启|参考地址：https://blog.csdn.net/taiyang1987912/article/details/41695895/</div>
            <div>find -type f -name '*.log'|xargs grep -r -E -o (25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?) /path/to</div>
            <div>正常情况下日志应该会用elasticsearch做存储</div>
            <div>4、服务器后端 api 接口与前端服务器分别架设在不同的服务器上，应该如何做跨域验权来保证安全性？</div>
            <div>add_header Access-Control-Allow-Origin 前端域名;</div>
        </div>
        <!--ALTER TABLE stock_total ADD COLUMN `disclosure_time` date  COLLATE utf8_general_ci NOT NULL DEFAULT  '2020-03-31'-->
    </fieldset>
    <div class="demoTable">
        <div class="layui-inline">
            <input class="layui-input" name="key" id="key" placeholder="股票编号|股票名称">
        </div>
        <button class="layui-btn" id="search" data-type="reload">{:lang('search')}</button>
        <a href="{:url('index')}" class="layui-btn">显示全部</a>
        <!--<button type="button" class="layui-btn layui-btn-danger" id="delAll">批量删除</button>-->
        <button type="button" class="layui-btn layui-btn-primary" id="adBtn"><i class="icon icon-upload3"></i>rating_test导入</button>
        <button type="button" class="layui-btn layui-btn-primary" id="adBtn1"><i class="icon icon-upload3"></i>finance_guide导入</button>
        <!--<a href="{:url('add')}" class="layui-btn" style="float:right;"><i class="fa fa-plus" aria-hidden="true"></i>{:lang('add')}{:lang('ad')}</a>-->
        <div style="clear: both;"></div>
    </div>
    <table class="layui-table" id="list" lay-filter="list"></table>
</div>
{include file="common/foot"/}
<script type="text/html" id="title">
   {{d.title}}{{# if(d.pic){ }}<img src="/static/admin/images/image.gif" onmouseover="layer.tips('<img src={{d.pic}}>',this,{tips: [1, '#fff']});" onmouseout="layer.closeAll();">{{# } }}
</script>
<script type="text/html" id="order">
    <input name="{{d.id}}" data-id="{{d.id}}" class="list_order layui-input" value=" {{d.sort}}" size="10"/>
</script>
<script type="text/html" id="open">
    <input type="checkbox" name="open" value="{{d.id}}" lay-skin="switch" lay-text="开启|关闭" lay-filter="open" {{ d.open == 1 ? 'checked' : '' }}>
</script>
<script type="text/html" id="action">
    <a href="{:url('edit')}?id={{d.id}}" class="layui-btn layui-btn-xs">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script>
    layui.use(['table','form','upload'], function() {
        var table = layui.table,form = layui.form,$ = layui.jquery;upload = layui.upload;
        var tableIn = table.render({
            id: 'ad',
            elem: '#list',
            url: '{:url("index")}',
            method: 'post',
            page:true,
            cols: [[
                {checkbox: true, fixed: true},
                {field: 'id', title: '{:lang("id")}', width: 80, fixed: true},
                {field: 'stock_id', title: '股票编号', width: 80},
                {field: 'stock_name', title: '股票名称', width: 100},
                {field: 'Report_year', title: '报告时间', width: 200},
                {field: 'ROE', title: '股本回报率', width: 100},
                {field: 'Net_profit', title: '净利润', width: 100},
                {field: 'profit_margin', title: '利润率', width: 100},
                {field: 'net_asset_per', title: '净资产', width: 100},
                {field: 'core_growth', title: '核心增长', width: 100},
                {field: 'NP_growth', title: 'NP_增长', width: 100},
                {field: 'rating', title: '评级'},
                // {field: 'open', align: 'center', title: '{:lang("status")}', width: 100, toolbar: '#open'},
                // {width: 160, align: 'center', toolbar: '#action'}
            ]],
            limit:10
        });
        form.on('switch(open)', function(obj){
            loading =layer.load(1, {shade: [0.1,'#fff']});
            var id = this.value;
            var open = obj.elem.checked===true?1:0;
            $.post('{:url("editState")}',{'id':id,'open':open},function (res) {
                layer.close(loading);
                if (res.status==1) {
                    tableIn.reload();
                }else{
                    layer.msg(res.msg,{time:1000,icon:2});
                    return false;
                }
            })
        });
        $('#search').on('click', function () {
            var key = $('#key').val();
            if ($.trim(key) === '') {
                layer.msg('{:lang("pleaseEnter")}关键字！', {icon: 0});
                return;
            }
            tableIn.reload({ page: {page: 1}, where: {key: key}});
        });
        table.on('tool(list)', function(obj) {
            var data = obj.data;
            if (obj.event === 'del'){
                layer.confirm('您确定要删除该广告吗？', function(index){
                    var loading = layer.load(1, {shade: [0.1, '#fff']});
                    $.post("{:url('del')}",{id:data.id},function(res){
                        layer.close(loading);
                        if(res.code===1){
                            layer.msg(res.msg,{time:1000,icon:1});
                            tableIn.reload();
                        }else{
                            layer.msg('操作失败！',{time:1000,icon:2});
                        }
                    });
                    layer.close(index);
                });
            }
        });
        $('body').on('blur','.list_order',function() {
            var id = $(this).attr('data-id');
            var sort = $(this).val();
            var loading = layer.load(1, {shade: [0.1, '#fff']});
            $.post('{:url("adOrder")}',{id:id,sort:sort},function(res){
                layer.close(loading);
                if(res.code === 1){
                    layer.msg(res.msg, {time: 1000, icon: 1});
                    tableIn.reload();
                }else{
                    layer.msg(res.msg,{time:1000,icon:2});
                }
            })
        });
        $('#delAll').click(function(){
            layer.confirm('确认要删除选中的广告吗？', {icon: 3}, function(index) {
                layer.close(index);
                var checkStatus = table.checkStatus('ad'); //test即为参数id设定的值
                var ids = [];
                $(checkStatus.data).each(function (i, o) {
                    ids.push(o.id);
                });
                if(ids==''){
                    layer.msg('请选择要删除的数据！', {time: 1000, icon: 2});
                    return false;
                }
                var loading = layer.load(1, {shade: [0.1, '#fff']});
                $.post("{:url('delall')}", {ids: ids}, function (data) {
                    layer.close(loading);
                    if (data.code === 1) {
                        layer.msg(data.msg, {time: 1000, icon: 1});
                        tableIn.reload();
                    } else {
                        layer.msg(data.msg, {time: 1000, icon: 2});
                    }
                });
            });
        })
        //文件上传
        var uploadInst = upload.render({
            elem: '#adBtn'
            ,url: '{:url("UpFiles/importSqlFromTest")}'
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                // obj.preview(function(index, file, result){
                //     $('#adPic').attr('src', result); //图片链接（base64）
                // });
            },
            done: function(res){
                if(res.code>0){
                    $('#pic').val(res.url);
                }else{
                    //如果上传失败
                    return layer.msg('上传失败');
                }
            }
            ,error: function(){
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function(){
                    uploadInst.upload();
                });
            }
        });
        var uploadInst1 = upload.render({
            elem: '#adBtn1'
            ,url: '{:url("UpFiles/importSqlFromExcel")}'
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                // obj.preview(function(index, file, result){
                //     $('#adPic').attr('src', result); //图片链接（base64）
                // });
            },
            done: function(res){
                if(res.code>0){
                    $('#pic').val(res.url);
                }else{
                    //如果上传失败
                    return layer.msg('上传失败');
                }
            }
            ,error: function(){
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function(){
                    uploadInst.upload();
                });
            }
        });
    })
</script>